package com.cncytech.uiautomator_demo.testcase;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import android.util.Log;

import com.cncytech.uiautomator_demo.BaseTest;
import com.cncytech.uiautomator_demo.RetryWatcher;
import com.cncytech.uiautomator_demo.TestConstant;
import com.cncytech.uiautomator_demo.utils.Describe;

import org.junit.Rule;
import org.junit.Test;

/**
 * 蓝牙测试
 */
public class BluetoothPoliciesTest extends BaseTest {
    private static final String TAG = "BluetoothPoliciesTest";
    @Rule
    public RetryWatcher retryWatcher = new RetryWatcher(TestConstant.retryCount);

    @Test
    @Describe(TestConstant.BLUETOOTH_FORBIDDEN)
    public void bluetoothPoliciesOffTest() {
        String msg = "蓝牙禁用失败";
        int status = 0;

        assertThat(msg, hmm.setBluetoothPolicies(status, new String[]{}));
        String[] bluetoothPolicies = hmm.getBluetoothPolicies();

        assertThat(msg, bluetoothPolicies[0], is("0"));
    }


    /**
     * 这个需要想其他解决方案
     */
    // @Test
    @Describe(TestConstant.BLUETOOTH_FORBIDDEN)
    public void bluetoothPoliciesEnableTest() {
        String msg = "蓝牙允许部分失败";
        int status = 1;

        assertThat(msg, hmm.setBluetoothPolicies(status, new String[]{"{\"Mac\":\"2E-E9-CA-B6-07-BA\"}"}));
        String[] bluetoothPolicies = hmm.getBluetoothPolicies();

        for (String bluetoothPolicy : bluetoothPolicies) {
            Log.i(TAG, "bluetoothPoliciesEnableTest: " + bluetoothPolicy);
        }
        assertThat(msg, bluetoothPolicies[0], is(String.valueOf(status)));
    }

}
